Skip to content

feat: support server-only and client-only modules (#2162)#2167

Merged
brenelz merged 6 commits into
solidjs:mainfrom
YanAnghelp:feat/boundary-modules
Jul 18, 2026
Merged

feat: support server-only and client-only modules (#2162)#2167
brenelz merged 6 commits into
solidjs:mainfrom
YanAnghelp:feat/boundary-modules

Conversation

@YanAnghelp

Copy link
Copy Markdown
Contributor

Closes #2162

@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 390bce3
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a5af725efe1790008f2f129
😎 Deploy Preview https://deploy-preview-2167--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 390bce3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2167

commit: 390bce3

Comment thread packages/start/src/config/index.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class support in SolidStart’s Vite configuration for the conventional server-only and client-only modules, enabling build-time enforcement of server/client module boundaries (as requested in #2162).

Changes:

  • Add a Vite pre-enforced plugin that errors when server-only is imported in non-SSR builds or client-only is imported in SSR builds.
  • Add TypeScript module declarations for server-only and client-only to avoid TS resolution errors for side-effect imports.
  • Add a changeset to ship the feature as a minor bump for @solidjs/start.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/start/src/config/index.ts Introduces the boundary-enforcement Vite plugin for server-only / client-only.
packages/start/env.d.ts Declares server-only and client-only modules for TypeScript consumers.
.changeset/support-server-client-only.md Publishes the feature as a minor release change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/start/src/config/index.ts
Comment thread packages/start/src/config/index.ts
Comment thread packages/start/src/config/index.ts
@YanAnghelp

Copy link
Copy Markdown
Contributor Author

To facilitate #2207, this plugin should be moved to a separate file. Should the changes be made directly in this PR or in #2207?

@lxsmnsyc

Copy link
Copy Markdown
Member

@brenelz I think instead of a separate plugin since this one is a superset of the server import guard, perhaps we can mark Start's server-only modules via import rather than the plugin in #2207 ?

@YanAnghelp

Copy link
Copy Markdown
Contributor Author

@lxsmnsyc In that case, the importer would be the internal module itself, making it difficult to pinpoint the error.

@lxsmnsyc

Copy link
Copy Markdown
Member

@YanAnghelp I'm not sure I understood. My point was that the #2207 change has a "server-only" module list, and I feel like instead we can utilize your plugin. Does it work or does the two plugin have to co-exist

@YanAnghelp

YanAnghelp commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@lxsmnsyc I think the same way. We only need to check the module list at the beginning of this plugin. We don't need two plugins. That's why I proposed that this plugin should be moved to a separate file to keep the code concise.

brenelz added a commit that referenced this pull request Jul 17, 2026
…a separate plugin

Per review feedback, drop the standalone server-only-guard plugin and
instead build on the boundary-modules plugin from #2167: the public
@solidjs/start/http and @solidjs/start/middleware entries now carry an
import "server-only" marker, so pulling them into the client bundle
fails at resolve time with an actionable error (#2068).

- extract boundary-modules into its own module and extend its errors
  with fix guidance ("use server" / clientOnly())
- split src/http into a marked public entry re-exporting ./http.ts, so
  the isomorphic <HttpHeader> (which guards usage behind isServer) can
  keep importing the helpers without tripping the client-env check
- @solidjs/start/config is no longer guarded: it is loaded directly by
  Node when evaluating vite.config.ts, outside the plugin pipeline, so
  it cannot carry the marker

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@brenelz
brenelz merged commit f3e84ec into solidjs:main Jul 18, 2026
10 of 11 checks passed
@YanAnghelp
YanAnghelp deleted the feat/boundary-modules branch July 18, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature?]: Built-in server-only & client-only virtual module

4 participants